package demo6;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet("/el")
public class demoELServlet extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException
    {
        // 处理GET请求的业务逻辑代码
        ArrayList<String> arrayList = new ArrayList<String>();
        arrayList.add("123");
        arrayList.add("456");
        arrayList.add("123");
        arrayList.add("789");
        arrayList.add("123");

        resp.setContentType("text/html; charset=UTF-8");
        req.setAttribute("req","req12");
        req.setAttribute("age","22");
        this.getServletContext().setAttribute("application","application12");
        this.getServletContext().setAttribute("age","23");
        this.getServletContext().setAttribute("arr1",arrayList);
        //重定向
        //resp.sendRedirect("/demoEL1.jsp");
        resp.sendRedirect("/jstl_demo5_forEach.jsp");
         //resp.sendRedirect("/jstl_demo5_forEach.jsp");
        //转发
        //req.getRequestDispatcher("/demoEL1.jsp").forward(req,resp);

    }
}
